<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script>
$.validator.addMethod("custom_number", function(value, element) {
    return this.optional(element) || value === "NA" || 
        value.match(/^[1-9]\d{3}$/);
}, "Enter valid ID");

$(document).ready(function(){
    $("#facilityform").validate({
        rules: {
            Id: {
                required: true,
                custom_number: true,
                minlength: 4
            }
        } 
    });
  });
</script>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<fmt:setBundle basename="Messages_en" />
<c:set var="t" value="true"/>
<title><fmt:message key="title"/></title>
</head>
<body>
<%@ include file="header.jsp" %>
<table>
<tr>
<td width=15%></td>
<td class="menuborder" width=20%>
<table id="head">
			<tr>
<!-- 				<td><h2 id="header">ISS Facilities Booking</h2></td> -->
				<td>
<!-- 				<input type="hidden" name="welcome" id="show_greeting" /> -->
				<c:if test="${!empty sessionScope.LoggedinUser.username}">
				<h5>Welcome ${sessionScope.LoggedinUser.username}</h5>
				</c:if>
				</td>
			</tr>
		</table>
		<table id="content">
			<tr>
				<td><h2 id="header">MENU</h2></td>
			</tr>
			<tr>
				<td><a href="MakeABooking.jsp">Make a Booking</a></td>
			</tr>
			<tr>
				<td><a href="BookDetailsController">View Booking Details</a></td>
			</tr>
			<tr>
				<td><a href="BookingHistoryController">View Booking History</a></td>
			</tr>
			<tr>
				<td><a href="ManageStaff.jsp">Manage Staff</a></td>
			</tr>
			<tr>
				<td><a href="LoadFacility">Manage Facilities</a></td>
			</tr>
			<tr>
				<td><a href="Login.jsp">Sign Out</a>
	
				</td>
			</tr>
		</table>
</td>
<td class=2%></td>
<td width=53%>
<form action="/JavaCA/process" method=post id="facilityform" >
<center>
<fieldset>
<legend><fmt:message key="setup.title"/></legend>
<table cellpadding=4 cellspacing=2 border=0>
<tr>
<td><fmt:message key="setup.facId"/>
</td>
<td>
<c:if test="${param['insert']==t || insert==t}" >
<input type="text" name="Id" value="${param['Id']}" size=15 maxlength=4 >
<input type="hidden" name="ins" value="true" />
</c:if>
<c:if test="${param['update']==t}" >
<input type="text" name="Id" value="${param['Id']}" size=15 maxlength=4 readonly="readonly">
<input type="hidden" name="ins" value="false" />
</c:if>
</td>
</tr>
<tr>
<td><fmt:message key="setup.name"/>
</td>
<td>
<input type="text" name="name" value="${param['name']}" size=16 maxlength=20 class="required">
</td>
</tr>
<tr>
<tr>
<td><fmt:message key="setup.type"/>
</td>
<td>
 <select name="type" class="required">
        <option ></option>
        <option value="Auditorium" ${ param['type'] == "Auditorium" ? 'selected="selected"' : '' } >Auditorium</option>
        <option value="Classroom"${ param['type'] == "Classroom" ? 'selected="selected"' : '' }>Classroom</option>
        <option value="MeetingRoom"${ param['type'] == "MeetingRoom" ? 'selected="selected"' : '' }>MeetingRoom</option>
        <option value="DiscussionRoom"${ param['type'] == "DiscussionRoom" ? 'selected="selected"' : '' }>DiscussionRoom</option>
        <option value="MPH"${ param['type'] == "MPH" ? 'selected="selected"' : '' }>MPH</option>
        </select>
</td>
</tr>
<tr>
<td><fmt:message key="setup.description"/>
</td>
<td>  
<input type="text"  name="description" value="${param['description']}" maxlength=550 class="required" />
</td>
</tr>
<tr>
<td><fmt:message key="setup.capacity"/>
</td>
<td><input type="text" name="capacity" value="${param['capacity']}" size=7 maxlength=11 class="required digits">
</td>
</tr>
</table>
${error}
<input type="submit" value="Submit"> <input type="reset"  value="Reset">
</fieldset>
</center>
</form>
</td>
<td width=10%></td>
</tr>
</table>
<%@ include file="footer.jsp" %>
</body>
</html>
